"use strict";
var crypto = require('crypto');
module.exports = {
    md5: md5,
    aes: aes,
    deaes: deaes
};
function md5(txt) {
    return crypto.createHash("md5").update(txt).digest("hex");
}
function aes(txt, key, iv, type = 'aes-256-cbc') {
    let cipher = crypto.createCipheriv(type, key, iv);
    let encrypted = cipher.update(txt, 'utf8', 'base64');
    encrypted += cipher.final('base64');
    return encrypted;
}
function deaes(txt, key, iv, type = 'aes-256-cbc') {
    let decipher = crypto.createDecipheriv(type, key, iv);
    let decrypted = decipher.update(txt, 'base64', 'utf8');
    decrypted += decipher.final('utf8');
    return decrypted;
}